import sys

import requests

from api.base import Login


class merProductAttr(Login):
    # 查询
    def product_rule_list(self, keywords=None):
        data = {
            'url': '/api/admin/merchant/product/rule/list',
            'method': 'get',
            'headers': {'Authori-zation': self._mer_token},
            'params': {
                'page': '1',
                'limit': '20',
                'keywords': keywords,
                'temp': '1726675946',
            }
        }
        return self.mer_send_request(sys._getframe().f_code.co_name,data)

    # 新增商品规格
    def product_rule_save(self, ruleName):
        data = {
            'url': '/api/admin/merchant/product/rule/save',
            'method': 'post',
            'headers': {'Authori-zation': self._mer_token},
            'json': {
                'id': 0,
                'ruleName': ruleName,
                'ruleValue': '[{"value":"10","detail":["20"]}]',
            }
        }
        return self.mer_send_request(sys._getframe().f_code.co_name,data)

    # 删除商品规格
    def product_rule_delete(self, pid):
        data = {
            'url': f'/api/admin/merchant/product/rule/delete/{pid}',
            'method': 'post',
            'headers': {'Authori-zation': self._mer_token},
        }
        return self.mer_send_request(sys._getframe().f_code.co_name,data)
